//
//  SYFDXQTableTableViewCell.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/7/5.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYFDXQTableTableViewCell.h"


@interface SYFDXQTableTableViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *xuhaoLab;
@property (weak, nonatomic) IBOutlet UILabel *kaishiriqiLab;
@property (weak, nonatomic) IBOutlet UILabel *shichangLab;
@property (weak, nonatomic) IBOutlet UILabel *zhuangtaiLab;
@property (weak, nonatomic) IBOutlet UILabel *kaoqinLab;

@end


@implementation SYFDXQTableTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)guankanBtnClick:(id)sender {
    if (self.block) {
        self.block(1);
    }
}
- (IBAction)bofangBtnClick:(id)sender {
    if (self.block) {
        self.block(2);
    }
}
- (IBAction)xiangqingBtnClick:(id)sender {
    if (self.block) {
        self.block(3);
    }
}

- (void)setTutorModel:(SYDataTutorModel *)tutorModel {
    self.xuhaoLab.text = tutorModel.lessonTimes;

    NSInteger index = [self timeSwitchTimestamp:tutorModel.beginDate andFormatter:@"YYYY-MM-dd HH:mm:ss"];
    NSString *strtime = [self timestampSwitchTime:index andFormatter:@"MM-dd"];
    
    self.kaishiriqiLab.text = strtime;
    self.shichangLab.text = tutorModel.duration;
    self.kaoqinLab.text = [NSString stringWithFormat:@"%@/%@",tutorModel.attendStudents,tutorModel.totalstudents];
    self.zhuangtaiLab.text = tutorModel.statusName;
    
}

-(NSString *)timestampSwitchTime:(NSInteger)timestamp andFormatter:(NSString *)format{
    
    
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:format]; // （@"YYYY-MM-dd hh:mm:ss"）----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    
    [formatter setTimeZone:timeZone];
    
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timestamp];
    
    NSLog(@"1296035591  = %@",confromTimesp);
    
    
    
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    
    
    
    //NSLog(@"&&&&&&&confromTimespStr = : %@",confromTimespStr);
    
    
    
    return confromTimespStr;
    
}
- (NSInteger)timeSwitchTimestamp:(NSString *)formatTime andFormatter:(NSString *)format{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:format]; //(@"YYYY-MM-dd hh:mm:ss") ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    
    
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    
    [formatter setTimeZone:timeZone];
    
    
    
    NSDate* date = [formatter dateFromString:formatTime]; //------------将字符串按formatter转成nsdate
    
    //时间转时间戳的方法:
    
    NSInteger timeSp = [[NSNumber numberWithDouble:[date timeIntervalSince1970]] integerValue];
    
    
    
    NSLog(@"将某个时间转化成 时间戳&&&&&&&timeSp:%ld",(long)timeSp); //时间戳的值
    
    
    
    return timeSp;
    
}


@end























